class Solution(object):
    def dailyTemperatures(self, temperatures):
        """
        :type temperatures: List[int]
        :rtype: List[int]
        """
        data_len = len(temperatures)
        result = [0] * data_len
        q = []
        for i in range(data_len):
            if not q or temperatures[q[-1]] >= temperatures[i]:
                q.append(i)
            else:
                while q and temperatures[q[-1]] < temperatures[i]:
                    j = q.pop()
                    result[j] = i - j
                q.append(i)
        while q:
            j = q.pop()
            result[j] = 0
        return result
